package main

import "fmt"

func main() {
	ch1 := make(chan int)
	ch2 := make(chan int)
	// 开启 goroutine 将 0~100 的数值发送到ch1 中
	go func() {
		for i := 0; i < 100; i++ {
			ch1 <- i
		}
		close(ch1)
	}()

	go func() {
		for {
			v, ok := <-ch1
			if !ok {
				break
			}
			ch2 <- v * v
		}

		close(ch2)
	}()

	for i := range ch2 {
		fmt.Println(i)
	}
}
